*******************************
* IRCA and Redistricting
* Navid Sabet and Noam Yuchtman
* Figure 4: IRCA and county covariates (trends)
*******************************

	//Load data
	use irca_gerrymander.dta, clear

	//Fixed effects
	global fe id congress#StateFIPS c.hisp_share1980#i.congress i.unassigned_county#i.congress 
	
	//Clustering
	global cluster id
	
	//Keep relevant years/congressess
	keep if congress >=98
	
	//Drop single district states
	 drop if single_district1990==1 
	 
************************
* Event Studies
************************

//County Population
reghdfe population_bea_std c.irca_std##ib1992.year, a($fe) nocons  cluster($cluster) noomit
		forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(6)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Total Population ,size(normal))
		coefplot, $coefoptions 
		graph save "population_event_year.gph", replace
		graph export "population_event_year.pdf", replace
		
		
//Per Capita Income
reghdfe personal_inc_pc_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
				forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(6)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Per Capita Income,size(normal))
		
		coefplot, $coefoptions 
		graph save "income_pc_event_year.gph", replace
		graph export "income_pc_event_year.pdf", replace
		
				
//Education
reghdfe edu010_std c.irca_std##ib1992.year, a($fe) nocons  cluster($cluster) noomit
		forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(3)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Public School Enrolment,size(normal))
				coefplot, $coefoptions 
		graph save "education_event_year.gph", replace
		graph export "education_event_year.pdf", replace
				
											
//Births
reghdfe births_std c.irca_std##ib1992.year, a($fe) nocons  cluster($cluster) noomit
				forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(2)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Births per 1000,size(normal)) 
				coefplot, $coefoptions 
		graph save "births_event_year.gph", replace
		graph export "births_event_year.pdf", replace	
				
					
//Housing Value 
reghdfe housing_value_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
	forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(6)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Valuation of New Housing Units,size(normal))
				coefplot, $coefoptions 
		graph save "permits_value_event_year.gph", replace
		graph export "permits_value_event_year.pdf", replace	
		
	
//Social Security: Payments
reghdfe spr030_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
	forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(2)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Social Security - Payments,size(normal))
				coefplot, $coefoptions 
		graph save "social_security_amount_event_year.gph", replace
		graph export "social_security_amount_event_year.pdf", replace	
		
		
//Federal Grants
reghdfe fed150_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
				forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(5)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Federal Expenditure (Grants),size(normal))
				coefplot, $coefoptions 
		graph save "federal_grants_event_year.gph", replace
		graph export "federal_grants_event_year.pdf", replace	
		
//Violent Crimes 
reghdfe crime_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
				forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(6)  xtitle("Year") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(No. of Violent Crimes,size(normal))
				coefplot, $coefoptions 
		graph save "crimes_event_year.gph", replace
		graph export "crimes_event_year.pdf", replace	
		

//Employment
reghdfe employed_bls_std c.irca_std##ib1992.year, a($fe) nocons cluster($cluster) noomit
		forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(2)  xtitle("") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Employed,size(normal))
				coefplot, $coefoptions 
		graph save "employed_event_year.gph", replace
		graph export "employed_event_year.pdf", replace	
		

		
//Hispanic Persons
reghdfe hispanics_ftp_std c.irca_std##ib1992.year if year>=1990, a($fe) nocons  cluster($cluster) noomit
				forval i =1982(2)2000{
			local j `j' `i'.year#c.irca_std="`i'" 
			}
		global coeflabel_legalized "`j'"	
		
		global coefoptions  drop(_cons $control *.year irca_std) ///
			omitted ///
				ciopts(recast(rcap) lcolor(gs8)) msymbol(smcircle)  ytitle("") baselevels ylab( , nogrid)  ///
				levels(95) byopts(legend(off) row(1)) xlabel(,labsize(normal) angle(45)) xline(2)  xtitle("Year") ///
				coeflabels(${coeflabel_legalized})	yline(0) vertical title(Hispanic Persons,size(normal))
		coefplot, $coefoptions 
		
		graph save "hispanic_event_year.gph", replace
		graph export "hispanic_event_year.pdf", replace
		

			
************************
* Combine Graphs
************************	
	graph combine  "population_event_year.gph" "income_pc_event_year.gph" "federal_grants_event_year.gph" "education_event_year.gph" "permits_value_event_year.gph" "births_event_year.gph" "social_security_amount_event_year.gph" "employed_event_year.gph" "crimes_event_year.gph" "hispanic_event_year.gph", ycommon col(2) iscale(.5) ysize(10) graphregion(margin(zero)) 
	
graph export "fig4.pdf", replace
